﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@page import="com.util.PublicToolCheckParam" %>
<%@page import="com.entity.OrderInfo" %>
<%@page import="com.entity.CustomerDetailInfo" %>
<%@page import="com.dao.CustomerDetailInfoDAO" %>
<%@page import="com.dao.CustomerInfoDAO" %>
<%@page import="com.entity.CustomerInfo" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>门诊就诊管理</title>
    <link type="text/css" rel="stylesheet" href="../css/style.css"/>
    <script type="text/javascript" src="../js/third/manageOrder.js" charset="utf-8"></script>
</head>

<body>
<form action="../servlet/ManageOrder?method=deleteMore" method="post">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" style="font-size:13px;">
        <tr>
            <td width="100%" height="36"><strong><font color="#666666" size="3">门诊就诊管理</font></strong></td>
        </tr>
        <tr>
            <td height="40" colspan="4">
                <hr width="100%"/>
            </td>
        </tr>
        <tr>
            <td height="147" colspan="4">
                <table width="100%" border="1" cellpadding="0" cellspacing="0" style="font-size:13px" bordercolor="#cccccc">
                    <tr height="30">
                        <td>
                            <div align="center"><font color="#666666">就诊编号</font></div>
                        </td>
                        <td>
                            <div align="center"><font color="#666666">就诊状态</font></div>
                        </td>
                        <td>
                            <div align="center"><font color="#666666">就诊时间</font></div>
                        </td>
                        <td>
                            <div align="center"><font color="#666666">患者账户/邮箱</font></div>
                        </td>
                        <td>
                            <div align="center"><font color="#666666">患者</font></div>
                        </td>
                        <td>
                            <div align="center"><font color="#666666">移动电话</font></div>
                        </td>
                        <td>
                            <div align="center"><font color="#666666">操作</font></div>
                        </td>
                    </tr>
                    <%
                        ArrayList<OrderInfo> orderInfoList = (ArrayList<OrderInfo>) request.getAttribute("orderInfoList");
                        CustomerDetailInfoDAO cddao = new CustomerDetailInfoDAO();
                        CustomerInfoDAO cdao = new CustomerInfoDAO();
                        if (orderInfoList == null || orderInfoList.toString().equals("[]")) {
                            out.println("<td colspan='10' height='30'><div align='center'>当前无任何就诊信息!</div></td>");
                        } else {
                            for (int i = 0; i < orderInfoList.size(); i++) {
                                OrderInfo od = orderInfoList.get(i);
                                CustomerDetailInfo customerDetailInfo = cddao.getCustomerDetailInfo(od.getCustomerId());
                                CustomerInfo customerInfo = cdao.getCustomerInfo(customerDetailInfo.getCustomerId());
                                String lsdate = (String) request.getAttribute("lsdate");
                                out.println("<tr height='30'>");
                                out.println("<td><div align='center'>" + od.getOrderId() + "</div></td>");
                                if (lsdate.equals("now")) {
                                    if (od.getStatus() == 0) {
                                        out.println("<td><div align='center'><font color='#FF0000'>已挂号排队中</font></div></td>");
                                    } else if (od.getStatus() == 1) {
                                        out.println("<td><div align='center'>检查缴费</div></td>");
                                    } else if (od.getStatus() == 100) {
                                        out.println("<td><div align='center'>治疗完毕</div></td>");
                                    } else if (od.getStatus() == 101) {
                                        out.println("<td><div align='center'>已复诊</div></td>");
                                    }else if (od.getStatus() == 99) {
                                    	out.println("<td><div align='center'>已取消排队</div></td>");
                                    }
                                } else {
                                    out.println("<td><div align='center'>已过期</div></td>");
                                }
                                out.println("<td><div align='center'>" + od.getOrderTime() + "</div></td>");
                                out.println("<td><div align='center'>" + customerInfo.getEmail() + "</div></td>");
                                out.println("<td><div align='center'>" + customerDetailInfo.getName() + "</div></td>");
                                out.println("<td><div align='center'>" + customerDetailInfo.getMovePhone() + "</div></td>");

                                out.println("<td><div align='center'>");


                                if (lsdate.equals("now")) {

                                    if (od.getStatus() == 0) {
                                        out.println("<a href='#' onclick=confirmOrder(" + od.getOrderId() + ",1," + session.getAttribute("thirdId") + ")>检查缴费</a>");
                                    } else if (od.getStatus() == 1) {
                                        out.println("<a href='#' onclick=confirmOrder(" + od.getOrderId() + ",100," + session.getAttribute("thirdId") + ")>治疗完毕买药</a>");
                                    }
                                }
                                if (od.getStatus() == 100) {
                                    out.println("<a href='#' onclick=confirmOrder(" + od.getOrderId() + ",101," + session.getAttribute("thirdId") + ")>复诊</a>");
                                }


                                out.println(" <a href='../servlet/tManageOrder?method=showDetail&orderId=" + od.getOrderId() + "'>详情</a> ");
                                out.println(" <a href='#' onclick=deleteOrder(" + od.getOrderId() + "," + session.getAttribute("thirdId") + ")>删除</a> ");

                                out.println("</div></td></tr>");

                            }
                        }
                    %>
                    <tr>
                        <td colspan="10" height="50">
                            <div align="center">共找到<%=request.getAttribute("sumCount")%>条记录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                第<%=request.getAttribute("currentPage")%>/<%=request.getAttribute("sumPageCount")%>页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <a href="../servlet/tManageOrder?method=<%out.println("showManageOrderPage");%>&cp=<%=request.getAttribute("indexPage")%>&lsdate=<%=request.getAttribute("lsdate")%>&thirdId=<%=request.getAttribute("thirdId")%>">首页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <a href="../servlet/tManageOrder?method=<%out.println("showManageOrderPage");%>&cp=<%=request.getAttribute("upPage")%>&lsdate=<%=request.getAttribute("lsdate")%>&thirdId=<%=request.getAttribute("thirdId")%>">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <a href="../servlet/tManageOrder?method=<%out.println("showManageOrderPage");%>&cp=<%=request.getAttribute("nextPage")%>&lsdate=<%=request.getAttribute("lsdate")%>&thirdId=<%=request.getAttribute("thirdId")%>">下一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <a href="../servlet/tManageOrder?method=<%out.println("showManageOrderPage");%>&cp=<%=request.getAttribute("lastPage")%>&lsdate=<%=request.getAttribute("lsdate")%>&thirdId=<%=request.getAttribute("thirdId")%>">尾页</a>
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</form>
</body>
</html>
